import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/material.dart';
import 'package:flutter_deer/shop/models/agent_user_entity.dart';
import 'package:flutter_deer/widgets/state_layout.dart';

class AgentUserProvider extends ChangeNotifier {

  StateType? _stateType = StateType.loading;
  StateType? get stateType => _stateType;
  List<AgentUserEntity>? _agentUserList;
  int? _totalUsers = 0;
  double? _totalMoney = 0.00;
  List<AgentUserEntity>? get agentUserList => _agentUserList;
  int? get totalUsers => _totalUsers;
  double? get totalMoney => _totalMoney;
  bool? get empty => _agentUserList?.isEmpty;

  void setAgentUserList(List<AgentUserEntity>? agentUsers) {
    _agentUserList = agentUsers;
    _totalUsers = agentUsers!.length;
    for(int i=0;i<agentUsers!.length;i++){
      double? score = agentUserList?.elementAt(i).winScore;
      _totalMoney = NumUtil.add(_totalMoney!, score!);
    }
    _stateType = StateType.agentUser;
    notifyListeners();
  }
}
